<?php


namespace app\handler;


class Param
{
    public function planParam($param, $query)
    {
        if (!empty($param['type'])) {
            $query->where('type', 'like', "%{$param['type']}%");
        }
        if (!empty($param['species'])) {
            $query->where('species', 'like', "%{$param['species']}%");
        }

        return $query;
    }
    public function userParam($param, $query)
    {
        if (!empty($param['name'])) {
            $query->where('name', 'like', "%{$param['name']}%");
        }
        if (!empty($param['phone'])) {
            $query->where('phone', 'like', "%{$param['phone']}%");
        }

        return $query;
    }

    public function companyParam($param, $query)
    {
        if (!empty($param['name'])) {
            $query->where('name', 'like', "%{$param['name']}%");
        }
        if (!empty($param['contactPerson'])) {
            $query->where('contactPerson', 'like', "%{$param['contactPerson']}%");
        }
        if (!empty($param['telephone'])) {
            $query->where('telephone', 'like', "%{$param['telephone']}%");
        }
        if (!empty($param['phone'])) {
            $query->where('phone', 'like', "%{$param['phone']}%");
        }
        if (!empty($param['state'])) {
            $query->where('state', $param['state']);
        }

        return $query;
    }

    public function userplanParam($param, $query)
    {
        if (!empty($param['planId'])) {
            $query->where('planId', $param['planId']);
        }
        if (!empty($param['studentName'])) {
            $query->where('studentName', 'like', "%{$param['studentName']}%");
        }
        if (!empty($param['phone'])) {
            $query->where('phone', 'like', "%{$param['phone']}%");
        }

        if (!empty($param['companyName'])) {
            $query->where('companyName', 'like', "%{$param['companyName']}%");
        }

        return $query;
    }

    public function signupParam($param, $query)
    {
        if (!empty($param['planId'])) {
            $query->where('planId', $param['planId']);
        }
        if (!empty($param['studentName'])) {
            $query->where('studentName', 'like', "%{$param['studentName']}%");
        }
        if (!empty($param['testingTime'])) {
            $query->where('testingTime', 'like', "%{$param['testingTime']}%");
        }
        if (!empty($param['phone'])) {
            $query->where('phone', 'like', "%{$param['phone']}%");
        }
        if (!empty($param['type'])) {
            $query->where('type', 'like', "%{$param['type']}%");
        }
        if (!empty($param['companyName'])) {
            $query->where('companyName', 'like', "%{$param['companyName']}%");
        }

        return $query;
    }

    public function scoreParam($param, $query)
    {
        if (!empty($param['batch'])) {
            $query->where('batch', $param['batch']);
        }
        if (!empty($param['IDCard'])) {
            $query->where('IDCard', $param['IDCard']);
        }
        if (!empty($param['studentName'])) {
            $query->where('studentName', 'like', "%{$param['studentName']}%");
        }
        if (!empty($param['phone'])) {
            $query->where('phone', 'like', "%{$param['phone']}%");
        }

        if (!empty($param['companyName'])) {
            $query->where('companyName', 'like', "%{$param['companyName']}%");
        }
        if (!empty($param['examStatus'])) {
            $query->where('examStatus', 'like', "%{$param['examStatus']}%");
        }
        if (!empty($param['makeup'])) {
            $query->where('makeup', $param['makeup']);
        }
        if (!empty($param['training'])) {
            $query->where('training', $param['training']);
        }

        return $query;
    }

}